<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>已发消息 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">消息ID</div>
                    <div class="field">
                        <input name="msgId" id="msgId" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox" id="">
	              <div class="label">发布状态</div>
	                <div class="field">
	                <select name="pubStsCd"  id="pubStsCd" >
	                 <option value="  " selected="selected">--请选择--</option>
	                 <c:forEach items="${publist}" var="pub">
	                  <option value="${pub.key}">${pub.value}</option>
	                 </c:forEach>
	                </select>
	                </div>
           		</div>
				<div class="fieldBox" id="">
	              <div class="label">事业部</div>
	                <div class="field">
	                <select name="buOrgNm"  id="buOrgNm" >
	                 <option value="  " selected="selected">--请选择--</option>
	                 <c:forEach items="${orgList}" var="opt">
	                  <option value="${opt.key}">${opt.value}</option>
	                 </c:forEach>
	                </select>
	                </div>
           		</div>
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="addBtn" class="sq-button sq-button-round">群发消息</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,callback=null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
        url: '<%=path%>/splmsg/splBullMsgLM/initAlreadSendList.do',
        method: 'get',
        columns: [
		{display: '发布状态', name: 'pubStsCd', minWidth: 80, align: 'left', enabledSort: false},
		{display: '收到数', name: 'sndSuccNum', minWidth: 80, align: 'left', enabledSort: false},
		{display: '打开数', name: 'opnNum', minWidth: 80, align: 'left', enabledSort: false},
		{display: '消息ID', name: 'msgId', minWidth: 100, align: 'left', enabledSort: false},
		{display: '消息描述', name: 'descr', minWidth: 100, align: 'left', enabledSort: false},
		{display: '群发部门', name: 'buOrgNm', minWidth: 100, align: 'left', enabledSort: false},
		{display:  '群发对象', name: 'splNm', minWidth: 100, align: 'left',  enabledSort: false},
		{display: '群发地区', name: 'rgnPrNm', minWidth: 100, align: 'left', enabledSort: false},
		{display: '推送时间', name: 'pubTm', minWidth: 100, align: 'left', render:renderDate,enabledSort: false},
		{display: '编辑人', name: 'mdfUsrNm', minWidth: 100, align: 'left', enabledSort: false},
		{
			display: '操作',width: 150,
			render: function (rowdata, rowindex, value){
				var h1 ='';
				//h1 = '<a class="sq-button-hasicon" href="javascript:void(0);" onclick="modifySplBullMsg('+rowdata.id+')"><i class="sqBtnIco_4"></i>编辑</a>';
				if(rowdata.pubStsCd != '已发布'){
					h1 = '<a class="sq-button-hasicon" href="javascript:void(0);" onclick="modifySplBullMsg('+rowdata.id+')"><i class="sqBtnIco_4"></i>编辑</a>';
				}
				var h2 = '<a class="sq-button-hasicon" href="javascript:void(0);" onclick="delSplBullMsg('+rowdata.id+')"><i class="sqBtnIco_7"></i>删除</a>';
				return h1+h2;
			}
		}
            ],
            pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-20,
	        //isScroll: false,
	        checkbox:false,
	        delayLoad:true,
	        rownumbers:true,
        });
        grid.setHeight(100);
        
        $("#searchBar").ligerForm();
        grid.reload();
        $("#pageloading").hide();
        
        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });
        
        callback = function () {
            grid.reload();
        };

        /* 新增 */
        $("#addBtn").click(function (event) {
           Add_navTab("SplBullMsgLM_1", "群发消息", '<%=path%>/splmsg/splBullMsgLM/toAddPage.do', callback);
        });

       


    });
    
  //格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}
	  /* 修改 */
    function modifySplBullMsg(_id){
    	Add_navTab('SplBullMsgInfo_2'+_id, "修改消息", '<%=path%>/splmsg/splBullMsgLM/toModifyPage.do?id='+_id, callback);
    }
    /* 删除 */
    function delSplBullMsg(_id){
    	var _ids=[];
    	_ids.push(_id);
         $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
             if (flag == false)return;
             var wait_dialog;
             $.ajax({
                 type: 'post',
                 dataType: 'json',
                 data: {ids: JSON.stringify(_ids)},
                 url: '<%=path%>/splmsg/splBullMsgLM/removeByIds.do',
                 beforeSend: function () {
                     wait_dialog = $.ligerDialog.SQalert({
                         content: LogUtils.LOG_CMM_DATA_LOADING,
                         SQ_type: "waitting"
                     });
                 },
                 success: function (msg) {
                     wait_dialog.close();
                     if (msg.success == 1) {
                         $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                         grid.reload();
                     } else {
                         $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                     }
                 }
             });
         });
    }
       
    

</script>

</body>
</html>
